package de.stalinski.util;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;

public class HTMLUtil
{

    public ResultSet rs = null;

    public String HTML_TABLE_DEF_START = "<table class=\"Prices\" cellspacing=0>";

    public String HTML_TABLE_BODY_START = "<tbody>";

    public String HTML_TABLE_HEAD_START = "<thead>";

    public String HTML_TABLE_HEAD_END = "</thead>";

    public String HTML_TABLE_BODY_END = "</tbody>";

    public String HTML_TABLE_DEF_END = "</table>";

    public String HTML_TABLE_TD_START = "<td>";

    public String HTML_TABLE_TD_END = "</td>";

    public String HTML_TABLE_TR_START = "<tr>";

    public String HTML_TABLE_TR_END = "</tr>";

    public String HTML_TABLE_TH_START = "<th>";

    public String HTML_TABLE_TH_END = "</th>";

    public HTMLUtil()
    {
    }

    public String convertToTableField(String string) throws SQLException
    {
        String s = rs.getString(string);
        return HTML_TABLE_TD_START + s + HTML_TABLE_TD_END;
    }

    public String convertToTableDateField(String string) throws SQLException
    {
        String s = new SimpleDateFormat("dd-MM-yyyy").format(rs.getDate(string));
        return HTML_TABLE_TD_START + s + HTML_TABLE_TD_END;
    }

    public String ownField(String s) {
        return HTML_TABLE_TD_START + s + HTML_TABLE_TD_END;
    }

    public void setResultSet(ResultSet resSet)
    {
        rs = resSet;
    }

    public String createHeader(String s)
    {
        return HTML_TABLE_TH_START + s + HTML_TABLE_TH_END;
    }

}
